export default class Ajax {
    initEvent(options) {
        return new Promise((resolve) => {
            let _options = Object.assign({
                type: "get"
            }, options);
            let xhr = new XMLHttpRequest();
            xhr.open(_options.type, _options.url);
            if (window.VBArray) {//IE浏览器
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4) {
                        resolve(JSON.parse(xhr.responseText()));
                    }
                }
            } else {
                xhr.onload = function () {
                    resolve(JSON.parse(xhr.response));
                }
            }
            xhr.send();
        })

    }
}